$(function ($) {
    $("#chat").click(function(){
        run();
    });
    function run() 
    {  
        interval = setInterval(chat, "0");  
    }
    function chat() {
        // $("body").append("<div id='mask'></div>");
        $("#mask").addClass("mask").fadeIn("slow");
        $("#LoginBox").fadeIn("slow");  
        _scrollHeight = $(document).scrollTop();//获取当前窗口距离页面顶部高度 
        _windowHeight = $(window).height();//获取当前窗口高度 
        _windowWidth = $(window).width();//获取当前窗口宽度 
        _popupHeight = $("#LoginBox").height();//获取弹出层高度 
        _popupWeight = $("#LoginBox").width();//获取弹出层宽度 
        _posiTop = (_windowHeight - _popupHeight)/2 + _scrollHeight; 
        _posiLeft = (_windowWidth - _popupWeight)/2; 
        $("#LoginBox").css({"left": _posiLeft + "px","top":_posiTop + "px","display":"block"});//设置position 
   }
    //关闭
    $(".close_btn").on('click', function () {
        $("#LoginBox").fadeOut("fast");
        $("#mask").css({ display: 'none' });
        clearTimeout(interval);  //关闭定时器
    });
});